/**
 * @param {number[][]} logs
 * @return {number}
 */
 var maximumPopulation = function(logs) {
    let ans = 0, pre = 0
    for(let [x,y] of logs){
        let sum = logs.filter(item => {
            return item[0] <= x && item[1] > x
        }).length
        if(sum > pre){
            ans = x
            pre = sum
        }
        if(sum === pre)
            ans = Math.min(ans, x)
    }
    return ans
};